home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / f2c / may_5_92.lha / f2c.VMay_5_1992 / libF77 / cabs.c < prev    next >
Text File  |  1992-05-07  |  309b  |  22 lines

  1. double cabs(real, imag)
  2. double real, imag;
  3. {
  4. double temp, sqrt();
  5.  
  6. if(real < 0)
  7.     real = -real;
  8. if(imag < 0)
  9.     imag = -imag;
  10. if(imag > real){
  11.     temp = real;
  12.     real = imag;
  13.     imag = temp;
  14. }
  15. if((real+imag) == real)
  16.     return(real);
  17.  
  18. temp = imag/real;
  19. temp = real*sqrt(1.0 + temp*temp);  /*overflow!!*/
  20. return(temp);
  21. }
  22.